{% extends 'base/base.html' %}

{% block title %}仪表盘测试 - 多用户报警系统{% endblock %}

{% block content %}
<div class="mb-4">
    <h1 class="mb-4">
        <i class="fa fa-dashboard" aria-hidden="true"></i> 仪表盘测试
    </h1>
    
    <!-- Webhook清单 -->
    <div class="card mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h2 class="h4 mb-0">
                <i class="fa fa-plug" aria-hidden="true"></i> Webhook清单测试
            </h2>
        </div>
        <div class="card-body">
            {% if user_webhooks %}
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>Webhook名称</th>
                                <th>所属项目</th>
                                <th>渠道</th>
                                <th>状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for webhook in user_webhooks %}
                                <tr>
                                    <td>{{ webhook.name }}</td>
                                    <td><a href="{% url 'projects:project_detail' webhook.project.id %}">{{ webhook.project.name }}</a></td>
                                    <td>{{ webhook.get_channel_display }}</td>
                                    <td>
                                        {% if webhook.is_active %}
                                            <span class="badge bg-success">已激活</span>
                                        {% else %}
                                            <span class="badge bg-danger">已禁用</span>
                                        {% endif %}
                                    </td>
                                    <td>{{ webhook.created_at|date:"Y年m月d日 H:i" }}</td>
                                    <td>
                                        <a href="{% url 'projects:project_detail' webhook.project.id %}#webhooks" class="btn btn-sm btn-primary" title="查看详情">
                                            <i class="fa fa-eye" aria-hidden="true"></i>
                                        </a>
                                    </td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            {% else %}
                <p class="text-center text-muted">暂无Webhook数据</p>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}